<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>TurtleDB: src/ca/uqac/dim/turtledb/Attribute.java Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">TurtleDB
   
   </div>
   <div id="projectbrief">A mini distributed database system</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_attribute_8java.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">src/ca/uqac/dim/turtledb/Attribute.java</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_attribute_8java.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*-------------------------------------------------------------------------</span>
<a name="l00002"></a>00002 <span class="comment">    Simple distributed database engine</span>
<a name="l00003"></a>00003 <span class="comment">    Copyright (C) 2012  Sylvain Hallé</span>
<a name="l00004"></a>00004 <span class="comment"></span>
<a name="l00005"></a>00005 <span class="comment">    This program is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">    it under the terms of the GNU General Public License as published by</span>
<a name="l00007"></a>00007 <span class="comment">    the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">    (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment"></span>
<a name="l00010"></a>00010 <span class="comment">    This program is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">    GNU General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment">    You should have received a copy of the GNU General Public License</span>
<a name="l00016"></a>00016 <span class="comment">    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00017"></a>00017 <span class="comment"> -------------------------------------------------------------------------*/</span>
<a name="l00018"></a><a class="code" href="namespaceca_1_1uqac_1_1dim_1_1turtledb.html">00018</a> <span class="keyword">package </span>ca.uqac.dim.turtledb;
<a name="l00019"></a>00019 
<a name="l00020"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">00020</a> <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a> <span class="keyword">extends</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_literal.html">Literal</a>
<a name="l00021"></a>00021 {
<a name="l00022"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">00022</a>   <span class="keyword">protected</span> String <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a>;
<a name="l00023"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">00023</a>   <span class="keyword">protected</span> String <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a>;
<a name="l00024"></a>00024   
<a name="l00025"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a518435300419960a407e072a989e948a">00025</a>   <span class="keyword">public</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a518435300419960a407e072a989e948a">Attribute</a>()
<a name="l00026"></a>00026   {
<a name="l00027"></a>00027     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a> = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00028"></a>00028     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a> = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00029"></a>00029   }
<a name="l00030"></a>00030   
<a name="l00037"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a54e4fcb14aab55630f2d206e3c4de6bc">00037</a>   <span class="keyword">public</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a518435300419960a407e072a989e948a">Attribute</a>(String s)
<a name="l00038"></a>00038   {
<a name="l00039"></a>00039     <span class="keyword">this</span>();
<a name="l00040"></a>00040     <span class="keywordflow">if</span> (!s.contains(<span class="stringliteral">&quot;.&quot;</span>))
<a name="l00041"></a>00041       <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a> = s;
<a name="l00042"></a>00042     <span class="keywordflow">else</span>
<a name="l00043"></a>00043     {
<a name="l00044"></a>00044       String[] parts = s.split(<span class="stringliteral">&quot;\\.&quot;</span>);
<a name="l00045"></a>00045       <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a> = parts[0];
<a name="l00046"></a>00046       <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a> = parts[1];
<a name="l00047"></a>00047     }
<a name="l00048"></a>00048   }
<a name="l00049"></a>00049   
<a name="l00050"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#afd0866c600a66f391db221136f79de6c">00050</a>   <span class="keyword">public</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a518435300419960a407e072a989e948a">Attribute</a>(String t, String s)
<a name="l00051"></a>00051   {
<a name="l00052"></a>00052     <span class="keyword">this</span>();
<a name="l00053"></a>00053     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a> = t;
<a name="l00054"></a>00054     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a> = s;
<a name="l00055"></a>00055   }
<a name="l00056"></a>00056   
<a name="l00061"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a6e7096136d4c0d6bcadfacee0d00bae2">00061</a>   <span class="keyword">public</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a518435300419960a407e072a989e948a">Attribute</a>(<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a> a)
<a name="l00062"></a>00062   {
<a name="l00063"></a>00063     <span class="keyword">this</span>();
<a name="l00064"></a>00064     <span class="keywordflow">if</span> (a == null)
<a name="l00065"></a>00065       <span class="keywordflow">return</span>;
<a name="l00066"></a>00066     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a> = <span class="keyword">new</span> String(a.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a>);
<a name="l00067"></a>00067     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a> = <span class="keyword">new</span> String(a.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a>);
<a name="l00068"></a>00068   }
<a name="l00069"></a>00069   
<a name="l00070"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#aaeb60bbc71fd9f4d88d984791a97d731">00070</a>   <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#aaeb60bbc71fd9f4d88d984791a97d731">setName</a>(String name)
<a name="l00071"></a>00071   {
<a name="l00072"></a>00072     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a> = name;
<a name="l00073"></a>00073   }
<a name="l00074"></a>00074   
<a name="l00075"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a0571679249446044c28bb450c020c00c">00075</a>   <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a0571679249446044c28bb450c020c00c">setTableName</a>(String name)
<a name="l00076"></a>00076   {
<a name="l00077"></a>00077     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a> = name;
<a name="l00078"></a>00078   }
<a name="l00079"></a>00079   
<a name="l00080"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a607a2ddb9db89ceab7d0201ccf4be3ba">00080</a>   <span class="keyword">public</span> String <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a607a2ddb9db89ceab7d0201ccf4be3ba">getName</a>()
<a name="l00081"></a>00081   {
<a name="l00082"></a>00082     <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a>;
<a name="l00083"></a>00083   }
<a name="l00084"></a>00084   
<a name="l00085"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d431dee8abd0b3dbd962e301ef8eef0">00085</a>   <span class="keyword">public</span> String <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d431dee8abd0b3dbd962e301ef8eef0">getTableName</a>()
<a name="l00086"></a>00086   {
<a name="l00087"></a>00087     <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a>;
<a name="l00088"></a>00088   }
<a name="l00089"></a>00089   
<a name="l00090"></a>00090   @Override
<a name="l00091"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a9524a46b15be5be6cb50a38b5fa6dcfc">00091</a>   <span class="keyword">public</span> String <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a9524a46b15be5be6cb50a38b5fa6dcfc">toString</a>()
<a name="l00092"></a>00092   {
<a name="l00093"></a>00093     String out = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a>;
<a name="l00094"></a>00094     <span class="keywordflow">if</span> (!<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a>.isEmpty())
<a name="l00095"></a>00095       out = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a> + <span class="stringliteral">&quot;.&quot;</span> + out;
<a name="l00096"></a>00096     <span class="keywordflow">return</span> out;
<a name="l00097"></a>00097   }
<a name="l00098"></a>00098   
<a name="l00099"></a>00099   @Override
<a name="l00100"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a2bf4494da4f2e49efe48a5ce0bc37479">00100</a>   <span class="keyword">public</span> <span class="keywordtype">boolean</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a2bf4494da4f2e49efe48a5ce0bc37479">equals</a>(Object o)
<a name="l00101"></a>00101   {
<a name="l00102"></a>00102     <span class="keywordflow">if</span> (o == null)
<a name="l00103"></a>00103       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00104"></a>00104     <span class="keywordflow">if</span> (!(o instanceof <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a>))
<a name="l00105"></a>00105       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00106"></a>00106     <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a2bf4494da4f2e49efe48a5ce0bc37479">equals</a>((Attribute) o);
<a name="l00107"></a>00107   }
<a name="l00108"></a>00108   
<a name="l00109"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a735940f0cd09c5ec0769e9062b07e3ab">00109</a>   <span class="keyword">public</span> <span class="keywordtype">boolean</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a2bf4494da4f2e49efe48a5ce0bc37479">equals</a>(<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a> a)
<a name="l00110"></a>00110   {
<a name="l00111"></a>00111     <span class="keywordflow">if</span> (a == null)
<a name="l00112"></a>00112       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00113"></a>00113     <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a>.compareTo(a.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a>) == 0 
<a name="l00114"></a>00114         &amp;&amp; <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a>.compareTo(a.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a>) == 0;
<a name="l00115"></a>00115   }
<a name="l00116"></a>00116   
<a name="l00117"></a>00117   @Override
<a name="l00118"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a8b2a190b35af3b90dbb1502bd3202921">00118</a>   <span class="keyword">public</span> <span class="keywordtype">int</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a8b2a190b35af3b90dbb1502bd3202921">hashCode</a>()
<a name="l00119"></a>00119   {
<a name="l00120"></a>00120     <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a>.hashCode() + <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a>.hashCode();
<a name="l00121"></a>00121   }
<a name="l00122"></a>00122 
<a name="l00123"></a>00123   @Override
<a name="l00124"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a150423d73d966679cd472859abadeb5a">00124</a>   <span class="keyword">public</span> <span class="keywordtype">int</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a150423d73d966679cd472859abadeb5a">compareTo</a>(<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_literal.html">Literal</a> o)
<a name="l00125"></a>00125   {
<a name="l00126"></a>00126     <span class="keywordflow">if</span> (o instanceof <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_value.html">Value</a>)
<a name="l00127"></a>00127       <span class="keywordflow">return</span> -1; <span class="comment">// All attributes go before all values</span>
<a name="l00128"></a>00128     assert o instanceof <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a518435300419960a407e072a989e948a">Attribute</a>;
<a name="l00129"></a>00129     <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a150423d73d966679cd472859abadeb5a">compareTo</a>((Attribute) o);
<a name="l00130"></a>00130   }
<a name="l00131"></a>00131   
<a name="l00132"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#aef6985d091865d3ab73223dd04a8052a">00132</a>   <span class="keyword">public</span> <span class="keywordtype">int</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a150423d73d966679cd472859abadeb5a">compareTo</a>(<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a> o)
<a name="l00133"></a>00133   {
<a name="l00134"></a>00134     <span class="keywordtype">int</span> compare_table = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a>.compareTo(o.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7b0944b1d234a4997683ac12c380dfdd">m_tableName</a>);
<a name="l00135"></a>00135     <span class="keywordflow">if</span> (compare_table &lt; 0)
<a name="l00136"></a>00136       <span class="keywordflow">return</span> -1;
<a name="l00137"></a>00137     <span class="keywordflow">if</span> (compare_table &gt; 0)
<a name="l00138"></a>00138       <span class="keywordflow">return</span> 1;
<a name="l00139"></a>00139     <span class="keywordflow">if</span> (compare_table == 0)
<a name="l00140"></a>00140     {
<a name="l00141"></a>00141       <span class="keywordtype">int</span> compare_attName = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a>.compareTo(o.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a7d9283f498fac75e6cc9d038b6131960">m_value</a>);
<a name="l00142"></a>00142       <span class="keywordflow">if</span> (compare_attName == 0)
<a name="l00143"></a>00143         <span class="keywordflow">return</span> 0;
<a name="l00144"></a>00144       <span class="keywordflow">if</span> (compare_attName &lt; 0)
<a name="l00145"></a>00145         <span class="keywordflow">return</span> -1;
<a name="l00146"></a>00146       <span class="keywordflow">if</span> (compare_attName &gt; 0)
<a name="l00147"></a>00147         <span class="keywordflow">return</span> 1;
<a name="l00148"></a>00148     }
<a name="l00149"></a>00149     <span class="keywordflow">return</span> 0;
<a name="l00150"></a>00150   }
<a name="l00151"></a>00151 }
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_attribute_8java.html">Attribute.java</a>      </li>

    <li class="footer">Generated on Fri Dec 7 2012 18:55:40 for TurtleDB by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
